home *** CD-ROM | disk | FTP | other *** search
-
- /* txtwdth.c -- textwidth, p.864 */
- #include <graphics.h>
- char text[] = "Text to be underlined";
- main()
- {
- int graphdriver = DETECT, graphmode, xmax, ymax, xsize, ysize;
- /* Detect and initialize graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- /* Display a graphics window with a text */
- xmax = getmaxx();
- ymax = getmaxy();
- xsize = xmax - 100;
- ysize = ymax - 60;
- setviewport(50, 30, xsize+50, ysize+30,1);
- setfillstyle(SOLID_FILL, RED);
- setcolor(YELLOW);
- bar3d(0,0,xsize,ysize,0,1);
- /* Print text then underline by drawing a line underneath */
- settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1);
- settextjustify(LEFT_TEXT, BOTTOM_TEXT);
- outtextxy(10, ysize/2, text);
- moveto(10, ysize/2+1);
- /* Draw the underline */
- linerel(textwidth(text),0);
- /* Wait until a key is pressed */
- moveto(10,ysize-10);
- outtext("Press any key to exit:");
- getch();
- closegraph(); /* Exit graphics library */
- }